﻿namespace AlgLrnLib.Searching
{
    public class LinearSearch : BaseSearch
    {
        public override int FindIndex(int[] numbers, int number, DebugTraceDelegate DEBUG_TRACE)
        {
            return LinearFindIndex(numbers, number, DEBUG_TRACE);
        }

        private int LinearFindIndex(int[] numbers, int number, DebugTraceDelegate DEBUG_TRACE)
        {
            for (int i = 0; i < numbers.Length; i++)
            {
                if (numbers[i] == number)
                    return i;
            }

            return -1;
        }
    }
}
